<template>
  <div class="assess">
    <Header></Header>
    <div class="assessMain">
      <p class='current-nav2'>当前位置 : <router-link to='index'>首页</router-link> <i> > </i><a>{{companyName}}预案评审</a></p>

      <div class="mianOut">
        <div class="mianInner1">
          <div class="assess-title1">
            <h3>{{companyName}}预案评审</h3>
            <p>评审专家信息</p>
          </div>
          <el-table ref="multipleTable"
          :row-class-name="tableRowClassName"
                    :data="expertList">
            <el-table-column type="index"
                             align='center'
                             label='序号'
                             width="50">
            </el-table-column>
            <el-table-column prop="userName"
                             label="专家姓名"
                             align='center'
                             width='100'>
            </el-table-column>
            <el-table-column prop="companyName"
                             label="工作单位"
                             align='center'
                             width='200'
                             show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="title"
                             label="职称"
                             align='center'
                             show-overflow-tooltip
                             width='100'>
            </el-table-column>
            <el-table-column prop="buesinessName"
                             label="所属行业"
                             align='center'>
            </el-table-column>
            <el-table-column prop="phone"
                             label="联系电话"
                             align='center'>
            </el-table-column>
            <el-table-column prop="regionName"
                             label="地区"
                             align='center'>
            </el-table-column>
            <el-table-column
                             label="身份"
                             align='center'>

             <template slot-scope="scope">
					{{scope.row.identity ==1 ? '组长' :'组员'}}
				</template>
            </el-table-column>
          </el-table>
        </div>
        <div class="mianInner2" v-if="btnShow">
          <p>
            {{planSummaryName}}
            <a @click="goExam" 
                         class="enterAssess">进入评审
            </a>
          </p>
        </div>
      </div>
    </div>
    <Footer />
  </div>
</template>

<script>
import Header from '../common/header2'
import Footer from '../common/footer'
import config from '../../config.js'
export default {
  components: {
    Header,
    Footer
  },
  data () {
    return {
      flag:false,
        btnShow: true,
        planSummaryName: '',
        planSummaryNames: '',
        companyName:"",
        planSummaryId:'',
        expertList: [],
        currentPage: 1,
        pageSize: 10,
        total: 0
        };
  },
  created () {
      this.companyName = localStorage.plancompanyName
      this.getExpertList()
      this.hasOverTime()
      this.planSummaryName = this.$route.query.planSummaryName.split('.docx')[0]
      this.planSummaryId = this.$route.query.id
      this.planSummaryNames = this.$route.query.planSummaryName
      this.getSign()
  },
  methods: {
    getSign(){
         let url = config.baseUrl + 'special/v1.0/special/downloadautograph?userId='+localStorage.userid
  this.$axios.get(url)
         .then(res=>{
             if(res.data.meta.success){
               this.flag=true
                if( res.data.data.photoUrl){
  localStorage.signImg = res.data.data.photoUrl
              }
              if( res.data.data.autograph){
  localStorage.autograph = res.data.data.autograph
              }
            }else{
                this.flag=false
            } 
         })
    },
    tableRowClassName({row, rowIndex}) {
      if(row.userId == localStorage.userid){
          return 'success-row';
      }
        return '';
      },
    goExam(){
      if(this.flag){
        this.$router.push({name:'situationexam',params:{id:this.planSummaryId,name:this.planSummaryNames}})
      }else{
        this.$message.warning('请设置签名后再进行评审')
        setTimeout(() => {
          this.$router.push('uploadSign')
        }, 1000);
      }
    },
      getExpertList () {
        let url = config.baseUrl + 'planreview/v1.0/planreview/queryrecordslist'
        let params = {
             "current" : 1,
             "size": 5,
             "planSummaryId": this.$route.query.id
         }
         this.$axios(url,{params: params})
         .then((res) =>{
             if(res.data.meta.success){
                this.expertList = res.data.data.records
                this.expertList.map(item=>{
                  if(item.userId ==  localStorage.userid){
                    localStorage.identity = item.identity
                  }
                })
            }else{
                this.expertList = []
                if(res.data.meta.message!='暂时无数据'){
                    this.$message.warning(res.data.meta.message);
                }
               
                
            } 
         })
      },
      hasOverTime () {
        let url = config.baseUrl + 'bsReview/v1.0/review/query'
        let params = {
             "userId": JSON.parse(localStorage.getItem('user')).id,
             "planSummaryId": this.$route.query.id
         }
         this.$axios(url,{params: params})
         .then((res) =>{
             if(res.data.meta.success){
                 this.btnShow = true
            }else{
                this.btnShow = false
            } 
         }).catch((response) =>{
             console.log(response)
         })
      },
      handleCurrentChange (val) {
          this.currentPage = val
          this.getExpertList()
      }
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less'>
@import "../../../static/css/assess.less";
.success-row{
  background:#f0f9eb!important;
}
</style>
